//封装获取频道列表的逻辑
import { useState,useEffect } from "react";
import { getChannelApi } from "@/apis/article";

function useChannel(){
    //1.获取频道列表所有的逻辑
    const [channelList, setChannelList] = useState([])

    useEffect(() => {
        const getChannel = async () => {
            const res = await getChannelApi();
            setChannelList(res.data.channels)
        }
        //调用函数
        getChannel()
    }, [])
    //2.把组件用到的数据return
    return {
        channelList
    }
}

export {
    useChannel
}